/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.18                          *
*        Compiled Sep 19 2012, 13:49:08                              *
*        (c) 2011 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"
#include "MULTIPAGE.h"
#include "lcd_cortex.h"
#include "buzzer.h"
/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define COLOR_BACK0   0xFF3333
#define COLOR_BACK1   0x550000

#define COLOR_BORDER  0x444444
#define COLOR_KEYPAD0 0xAAAAAA
#define COLOR_KEYPAD1 0x555555

#define BUTTON_COLOR0 0xEEEEEE
#define BUTTON_COLOR1 0xCCCCCC
#define BUTTON_COLOR2 0xCCCCCC
#define BUTTON_COLOR3 0xAAAAAA

#define BUTTON_SKINFLEX_RADIUS 4

#define ID_FRAMEWIN_0   (GUI_ID_USER + 0x00)
#define ID_MULTIEDIT_0  (GUI_ID_USER + 0x01)
#define ID_RADIO_0  (GUI_ID_USER + 0x02)
#define ID_BUTTON_0  (GUI_ID_USER + 0x03)
#define ID_BUTTON_1  (GUI_ID_USER + 0x04)
#define ID_CHECKBOX_0  (GUI_ID_USER + 0x05)
#define ID_DROPDOWN_0  (GUI_ID_USER + 0x06)
#define ID_LISTVIEW_0  (GUI_ID_USER + 0x07)
#define ID_BUTTON_KEYPAD          (GUI_ID_USER + 0x08)
#define ID_BUTTON_KEYPAD_ESC	(GUI_ID_USER + 0x09)
#define APP_INIT_LOWERCASE (WM_USER + 0)

/*********************************************************************
*
*       Types
*
**********************************************************************
*/
typedef struct {
  int xPos, yPos, xSize, ySize;
  const char * acLabel;
  void (* pfDraw)(WM_HWIN hWin);
} BUTTON_DATA;

typedef struct {
  int x, y, Delay;
} EVENT;

typedef struct {
  BUTTON_SKINFLEX_PROPS * pProp;
  int Index;
  BUTTON_SKINFLEX_PROPS PropOld;
} BUTTON_PROP;

static GUI_CONST_STORAGE unsigned long acReturn[] = {
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x50505050, 0x50505050,
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
  0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000,
  0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x50505050,
  0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
};

static GUI_CONST_STORAGE GUI_BITMAP bmReturn = {
  16, /* XSize */
  8, /* YSize */
  64, /* BytesPerLine */
  32, /* BitsPerPixel */
  (unsigned char *)acReturn,  /* Pointer to picture data */
  NULL  /* Pointer to palette */
 ,GUI_DRAW_BMP8888
};

static GUI_CONST_STORAGE unsigned long acUp[] = {
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x60606060, 0x60606060, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0x60606060, 0x30303030, 0x30303030, 0x60606060, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0x60606060, 0x30303030, 0xEFEFEFEF, 0xEFEFEFEF, 0x30303030, 0x60606060, 0xFFFFFFFF,
  0x60606060, 0x10101010, 0xAFAFAFAF, 0xFFFFFFFF, 0xFFFFFFFF, 0xAFAFAFAF, 0x10101010, 0x60606060,
  0x40404040, 0x40404040, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x40404040, 0x40404040,
  0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF
};

static GUI_CONST_STORAGE GUI_BITMAP bmUp = {
  8, /* XSize */
  8, /* YSize */
  32, /* BytesPerLine */
  32, /* BitsPerPixel */
  (unsigned char *)acUp,  /* Pointer to picture data */
  NULL  /* Pointer to palette */
 ,GUI_DRAW_BMP8888
};

static GUI_CONST_STORAGE unsigned long acBackSpace[] = {
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xA0A0A0A0, 0x20202020, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
};

static GUI_CONST_STORAGE GUI_BITMAP bmBackSpace = {
  16, /* XSize */
  8, /* YSize */
  64, /* BytesPerLine */
  32, /* BitsPerPixel */
  (unsigned char *)acBackSpace,  /* Pointer to picture data */
  NULL  /* Pointer to palette */
 ,GUI_DRAW_BMP8888
};

static void _DrawCentered(WM_HWIN hWin, const GUI_BITMAP * pBM) {
  int xSizeWin, ySizeWin, xSizeBMP, ySizeBMP, xPos, yPos;

  xSizeWin = WM_GetWindowSizeX(hWin);
  ySizeWin = WM_GetWindowSizeY(hWin);
  xSizeBMP = pBM->XSize;
  ySizeBMP = pBM->YSize;
  xPos = (xSizeWin - xSizeBMP) >> 1;
  yPos = (ySizeWin - ySizeBMP) >> 1;
  GUI_DrawBitmap(pBM, xPos, yPos);
}

static void _DrawBkSpc (WM_HWIN hWin) {  _DrawCentered(hWin, &bmBackSpace); }
static void _DrawReturn(WM_HWIN hWin) {  _DrawCentered(hWin, &bmReturn); }
static void _DrawShift (WM_HWIN hWin) {  _DrawCentered(hWin, &bmUp); }

static WM_HWIN hKeypad;

static const BUTTON_DATA _aButtonData[] = {
  {   6,   6,  24, 24, "Q" },
  {  32,   6,  24, 24, "W" },
  {  58,   6,  24, 24, "E" },
  {  84,   6,  24, 24, "R" },
  { 110,   6,  24, 24, "T" },
  { 136,   6,  24, 24, "Z" },
  { 162,   6,  24, 24, "U" },
  { 188,   6,  24, 24, "I" },
  { 214,   6,  24, 24, "O" },
  { 240,   6,  24, 24, "P" },
  { 266,   6,  24, 24, "-" },
  { 292,   6,  24, 24, "\x8", _DrawBkSpc },
  {  16,  34,  24, 24, "A" },
  {  42,  34,  24, 24, "S" },
  {  68,  34,  24, 24, "D" },
  {  94,  34,  24, 24, "F" },
  { 120,  34,  24, 24, "G" },
  { 146,  34,  24, 24, "H" },
  { 172,  34,  24, 24, "J" },
  { 198,  34,  24, 24, "K" },
  { 224,  34,  24, 24, "L" },
  { 250,  34,  24, 24, ":" },
  { 276,  34,  40, 24, "\x0d", _DrawReturn },
  {   6,  62,  24, 24, "\x19", _DrawShift },
  {  32,  62,  24, 24, "Y" },
  {  58,  62,  24, 24, "X" },
  {  84,  62,  24, 24, "C" },
  { 110,  62,  24, 24, "V" },
  { 136,  62,  24, 24, "B" },
  { 162,  62,  24, 24, "N" },
  { 188,  62,  24, 24, "M" },
  { 214,  62,  24, 24, "," },
  { 240,  62,  24, 24, "." },
  { 266,  62,  24, 24, "!" },
  { 292,  62,  24, 24, "\x19", _DrawShift },
  {   6,  90,  37, 24, "Ctrl" },
  {  45,  90,  37, 24, "Alt" },
  {  84,  90, 154, 24, " " },
  { 240,  90,  37, 24, "Esc" },
  { 279,  90,  37, 24, "Ctrl" },
};


// USER START (Optionally insert additional defines)
// USER END

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

// USER START (Optionally insert additional static data)
// USER END

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
  { WINDOW_CreateIndirect,    "Dialog 1", 0, 0, 0, 300, 208, FRAMEWIN_CF_MOVEABLE },
  { MULTIEDIT_CreateIndirect, "Multiedit", ID_MULTIEDIT_0, 95, 11, 80, 60, 0, 0, 0 },
  { RADIO_CreateIndirect, "Radio", ID_RADIO_0, 16, 10, 80, 60, 0, 5123, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 18, 122, 80, 20, 0, 0, 0 },
  { BUTTON_CreateIndirect, "Relay", ID_BUTTON_1, 18, 146, 80, 20, 0, 0, 0 },
  { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 20, 86, 80, 20, 0, 0, 0 },
  { DROPDOWN_CreateIndirect, "Dropdown", ID_DROPDOWN_0, 193, 8, 80, 57, 0, 0, 0 },
  { LISTVIEW_CreateIndirect, "Listview", ID_LISTVIEW_0, 111, 81, 180, 120, 0, 0, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

static const GUI_WIDGET_CREATE_INFO _aDialogCreate2[] = {
  { WINDOW_CreateIndirect,    "Dialog 2", 0,                   0,   0, 260, 100, FRAMEWIN_CF_MOVEABLE },
  { CHECKBOX_CreateIndirect,  "",         GUI_ID_CHECK0,       5,  30,   0,   0, 0},
  { CHECKBOX_CreateIndirect,  "",         GUI_ID_CHECK1,       5,  50,   0,   0, 0},
  { TEXT_CreateIndirect,      "Select 0", GUI_ID_TEXT0,       25,  30,  50,  15, TEXT_CF_LEFT },
  { TEXT_CreateIndirect,      "Select 1", GUI_ID_TEXT1,       25,  50,  50,  15, TEXT_CF_LEFT },
  { TEXT_CreateIndirect,      "Dialog 2", 0,                   5,  10,  50,  20, TEXT_CF_LEFT }
};

static const GUI_WIDGET_CREATE_INFO _aDialogCreate3[] = {
  { WINDOW_CreateIndirect,    "Dialog 3", 0,                   0,   0, 260, 100, FRAMEWIN_CF_MOVEABLE },
  { RADIO_CreateIndirect,     "",         GUI_ID_RADIO0,       5,  30,   0,   0, 0, 3},
  { TEXT_CreateIndirect,      "Option 1", GUI_ID_TEXT0,       25,  30,  50,  15, TEXT_CF_LEFT },
  { TEXT_CreateIndirect,      "Option 2", GUI_ID_TEXT1,       25,  50,  50,  15, TEXT_CF_LEFT },
  { TEXT_CreateIndirect,      "Option 3", GUI_ID_TEXT2,       25,  70,  50,  15, TEXT_CF_LEFT },
  { TEXT_CreateIndirect,      "Dialog 3", 0,                   5,  10,  50,  20, TEXT_CF_LEFT }
};

static const char * Menu[][3] = {
  { "1", "1", "Item 1" },
  { "2", "2", "Item 2" },
  { "3", "3", "Item 3" },
  { "4", "4", "Item 4" },
  { "5", "5", "Item 5" },
  { "6", "6", "Item 6" },
  { "7", "7", "Item 7" },
  { "8", "8", "Item 8" }
};
/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

// USER START (Optionally insert additional static code)
// USER END

/*********************************************************************
*
*       _cbDialog
*/
void _ManageKeypad(void)
{
	static int keypadVisible  = 0;
	if(keypadVisible)
	{
		keypadVisible = 0;
		GUI_MEMDEV_ShiftOutWindow(hKeypad, 500, GUI_MEMDEV_EDGE_BOTTOM);
	}
	else
	{
		keypadVisible = 1;
		GUI_MEMDEV_ShiftInWindow(hKeypad, 500, GUI_MEMDEV_EDGE_BOTTOM);
	}
}
static WM_HWIN hDropdown;
static void _cbDialog1(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
  static unsigned char lampstate = 0;
  int Id, NCode;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Multiedit'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_MULTIEDIT_0);
    MULTIEDIT_SetAutoScrollH(hItem, 1);
    MULTIEDIT_SetAutoScrollV(hItem, 1);
    MULTIEDIT_SetWrapWord(hItem);
    MULTIEDIT_SetText(hItem, "Multiedit");

    //
    // Initialization of 'Radio'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0);
    RADIO_SetText(hItem, "Option1", 0);
    //
    // Initialization of 'Checkbox'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
    CHECKBOX_SetText(hItem, "Check");
    //
    // Initialization of 'Dropdown'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
    hDropdown = hItem;
    DROPDOWN_AddString(hItem, "Item1");
    DROPDOWN_AddString(hItem, "Item2");
    DROPDOWN_AddString(hItem, "Item3");
    //
    // Initialization of 'Listview'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
    LISTVIEW_AddColumn(hItem, 30, "Col 0", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 30, "Col 1", GUI_TA_HCENTER | GUI_TA_VCENTER);
    LISTVIEW_AddColumn(hItem, 30, "Col 2", GUI_TA_HCENTER | GUI_TA_VCENTER);
    uint8_t i;
    for (i = 0; i < GUI_COUNTOF(Menu); i++) {
        LISTVIEW_AddRow(hItem, Menu[i]);
      }
    LISTVIEW_SetRowHeight(hItem, 20);
    LISTVIEW_SetGridVis(hItem, 1);
    LISTVIEW_SetFont(hItem, &GUI_Font16B_ASCII);
    LISTVIEW_SetAutoScrollV(hItem, 1);
    LISTVIEW_SetGridVis(hItem, 0);
    LISTVIEW_SetColumnWidth(hItem, 0, 30);
    LISTVIEW_SetColumnWidth(hItem, 1, 120);
    LISTVIEW_SetColumnWidth(hItem, 2, 30);
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_MULTIEDIT_0: // Notifications sent by 'Multiedit'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END

    	//
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
    	  _ManageKeypad();
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_RADIO_0: // Notifications sent by 'Radio'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_0: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        vBUZZER_Beep(BUZZER_BEEP_SHORT);
       // _ManageKeypad();
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
      case ID_BUTTON_1: // Notifications sent by 'Button'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
            	if(lampstate)
            	{
            		LAMP_CLR;
            		lampstate = 0;
            	}
            	else
            	{
            		LAMP_SET;
            		lampstate = 1;
            	}

              break;
            case WM_NOTIFICATION_RELEASED:
              // USER START (Optionally insert code for reacting on notification message)
              // USER END
              break;
            // USER START (Optionally insert additional code for further notification handling)
            // USER END
            }
            break;
    case ID_CHECKBOX_0: // Notifications sent by 'Checkbox'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_VALUE_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_DROPDOWN_0: // Notifications sent by 'Dropdown'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_LISTVIEW_0: // Notifications sent by 'Listview'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_SEL_CHANGED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
static void _cbDialog2(WM_MESSAGE * pMsg) {
  WM_HWIN hDlg;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
  default:
    WM_DefaultProc(pMsg);
  }
}

static void _cbDialog3(WM_MESSAGE * pMsg) {
  WM_HWIN hDlg;
  hDlg = pMsg->hWin;
  switch (pMsg->MsgId) {
  default:
    WM_DefaultProc(pMsg);
  }
}

/*********************************************************************
*
*       _cbKeyPad
*
* Purpose:
*   Callback routine of keypad window
*/
static void _cbKeyPad(WM_MESSAGE * pMsg) {
  WM_HWIN hWin, hButton;
  int Id, NCode;
  int xSize, ySize, i;
  static int LowerCase;
  char c;

  hWin = pMsg->hWin;
  switch (pMsg->MsgId) {
  case APP_INIT_LOWERCASE:
    LowerCase = 0;
    break;
  case WM_CREATE:
    //
    // Create the keyboard buttons
    //
    for (i = 0; i < GUI_COUNTOF(_aButtonData); i++) {
      hButton = BUTTON_CreateEx(_aButtonData[i].xPos, _aButtonData[i].yPos, _aButtonData[i].xSize, _aButtonData[i].ySize,
                                hWin, WM_CF_SHOW | WM_CF_HASTRANS, 0, ID_BUTTON_KEYPAD + i);
      BUTTON_SetText(hButton, _aButtonData[i].acLabel);
      BUTTON_SetFocussable(hButton, 0);
    }
    break;
  case WM_PAINT:
    //
    // Draw background
    //
    xSize = WM_GetWindowSizeX(hWin);
    ySize = WM_GetWindowSizeY(hWin);
    GUI_SetColor(COLOR_BORDER);
    GUI_DrawRect(0, 0, xSize - 1, ySize - 1);
    GUI_DrawGradientV(1, 1, xSize - 2, ySize - 2, COLOR_KEYPAD0, COLOR_KEYPAD1);
    break;
  case WM_NOTIFY_PARENT:
    //
    // Send key message to currently focused window
    //
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch (NCode) {
    case WM_NOTIFICATION_RELEASED:
      if (_aButtonData[Id - ID_BUTTON_KEYPAD].acLabel) {
        c = _aButtonData[Id - ID_BUTTON_KEYPAD].acLabel[0];
        if (c == GUI_KEY_SHIFT) {
          LowerCase ^= 1;
        } else {
          if (LowerCase) {
            c |= 0x20;
          }
          GUI_StoreKeyMsg(c, 1);
          GUI_StoreKeyMsg(c, 0);
        }
      }
      break;
    }
  }
}

static int _DrawSkinFlex_BUTTON(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo) {
  WM_HWIN hWin;
  int i, Id;
  void (* pfDraw)(WM_HWIN hWin);

  switch (pDrawItemInfo->Cmd) {
  case WIDGET_ITEM_DRAW_TEXT:
    //
    // Use private or default function for drawing bitmap or text
    //
    hWin = pDrawItemInfo->hWin;
    Id = WM_GetId(hWin);
    i = Id - ID_BUTTON_KEYPAD;
    pfDraw = _aButtonData[i].pfDraw;
    if (pfDraw) {
      pfDraw(hWin);
    } else {
      BUTTON_DrawSkinFlex(pDrawItemInfo);
    }
    break;

  default:
    //
    // Use the default skinning routine for processing all other commands
    //
    return BUTTON_DrawSkinFlex(pDrawItemInfo);
  }
  return 0;
}

/*********************************************************************
*
*       CreateDupa
*/
WM_HWIN CreateDupa(void);
WM_HWIN CreateDupa(void) {
  WM_HWIN hDialog, hMultiPage;

  GUI_CURSOR_Hide();
  //BUTTON_SetDefaultSkin(_DrawSkinFlex_BUTTON);
  hKeypad = WM_CreateWindowAsChild(0, 120, 320, 120, WM_HBKWIN, WM_CF_HIDE | WM_CF_STAYONTOP, _cbKeyPad, 0);
  BUTTON_SetDefaultSkinClassic();

	hMultiPage = MULTIPAGE_CreateEx(0, 0, 320, 240, WM_HBKWIN, WM_CF_SHOW, 0, 0);
	hDialog = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), &_cbDialog1, WM_UNATTACHED, 0, 0);
    MULTIPAGE_AddPage(hMultiPage, hDialog, "MENU");
	hDialog = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), &_cbDialog2, WM_UNATTACHED, 0, 0);
    MULTIPAGE_AddPage(hMultiPage, hDialog, "Konfigurancja");
	hDialog = GUI_CreateDialogBox(_aDialogCreate3, GUI_COUNTOF(_aDialogCreate3), &_cbDialog3, WM_UNATTACHED, 0, 0);
    MULTIPAGE_AddPage(hMultiPage, hDialog, "Kalibrancja");
    MULTIPAGE_SelectPage(hMultiPage, 0);
  return 0;
}

// USER START (Optionally insert additional public code)
// USER END

/*************************** End of file ****************************/
